package demo1;

class Graph {
    public void draw() {
        System.out.println("画图形");
    }
}

class Rectangle extends Graph{
    @Override
    public void draw() {
        System.out.println("画矩形!");
    }
}

class Cycle extends Graph{
    @Override
    public void draw() {
        System.out.println("画圆!");
    }
}

class Triangle extends Graph{
    @Override
    public void draw() {
        System.out.println("画三角形!");
    }
}

class Apple extends Graph{
    public void draw() {
        System.out.println("画苹果!");
    }
}

public class Test {
    public static void drawMap(Graph graph) {
        graph.draw();
    }

    public static void main(String[] args) {
        drawMap(new Rectangle());
        drawMap(new Cycle());
        drawMap(new Triangle());
        drawMap(new Apple());
    }

    public static void main1(String[] args) {
        Graph graph1 = new  Rectangle();
        graph1.draw();
        Graph graph2 = new Cycle();
        graph2.draw();
        Graph graph3 = new Triangle();
        graph3.draw();
    }
}
